package com.demo.chapter12date;

import java.time.LocalDate;
import java.time.Period;

//以年、月、日的方式对多个时间单位建模
public class PeriodDemo {

	public static void demo(){
		Period tenDays = Period.between(LocalDate.of(2014, 3, 8), LocalDate.of(2014, 3, 18));
		System.out.println(tenDays.getDays());

		Period tenDays2 = Period.ofDays(11);
		System.out.println(tenDays2.getDays());

		Period tenDays3 = Period.ofWeeks(2);
		System.out.println(tenDays3.getDays());

		//2年6个月1天
		Period tenDays4 = Period.of(2, 6 ,1);
		System.out.println(tenDays4.getYears());
		System.out.println(tenDays4.getMonths());
		System.out.println(tenDays4.getDays());
	}

	public static void main(String[] args) {
		demo();
	}

}
